package com.awei.project.strict;

import com.awei.project.model.entity.Team;
import org.junit.jupiter.api.Test;

import java.util.ArrayDeque;

/**
 * @author 小维哥
 * @version 1.2
 */
public class xx {
        @Test
        int ss(String str) {
                int num = 0;
                ArrayDeque<Character> arrayDeque = new ArrayDeque<>();
                for (int i = 0; i < str.length(); i++) {
                        int temp = 0;
                        char s = str.charAt(i);
                        Character character = s;
                        arrayDeque.addFirst(character);
                        if (Character.isDigit(character)) {
                                temp = (int) character;
                        }
                        if (character.equals('+')) {
                                num += temp;
                        }
                        if (character.equals('-')) {
                                num -= temp;
                        }
                        if (s == ')') {
                                do {
                                        character = arrayDeque.removeFirst();
                                        if (Character.isDigit(character)) {
                                                temp = (int) character;
                                        }
                                        if (character.equals('+')) {
                                                num += temp;
                                        }
                                        if (character.equals('-')) {
                                                num -= temp;
                                        }
                                } while (!character.equals('('));
                        } else {
                                arrayDeque.addFirst(s);
                        }
                }
                return num;
        }
}
